﻿using iTFF.WPF.CP;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using iTFF.WPF.Model.Artwork;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace iTFF.Tests
{


    /// <summary>
    ///This is a test class for ArtworksControlPanelTest and is intended
    ///to contain all ArtworksControlPanelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ArtworksControlPanelTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetArtworks
        ///</summary>
        [TestMethod()]
        public void GetArtworksTest()
        {
            ArtworksControlPanel target = new ArtworksControlPanel();

            List<Artwork> actual = target.GetArtworks("Kansas The Best Of Kansas");

            Assert.IsTrue(actual.Count > 0, "Results are empty");
            Assert.IsTrue(actual.Any(a => !string.IsNullOrEmpty(a.ImageURLMedium)), "No medium image url specified");
            Assert.IsTrue(actual.Any(a => !string.IsNullOrEmpty(a.ImageURLBig)), "No big image url specified");

        }

        /// <summary>
        ///A test for DownloadBigImage
        ///</summary>
        [TestMethod()]
        public void DownloadBigImageTest()
        {
            ArtworksControlPanel target = new ArtworksControlPanel();

            // get list
            List<Artwork> artworks = target.GetArtworks("Kansas The Best Of Kansas");

            var art = artworks.First(a => !string.IsNullOrEmpty(a.ImageURLBig));
            var stream = target.DownloadBigImage(art);

            Assert.IsTrue(stream.Length > 0, "ImageBig is empty");

            stream.Dispose();
        }

    }
}
